# 设定模块名称
set(TARGET backup_test)

# openssl加密算法库
# 设置OPENSSL的根目录
if (NOT DEFINED OPENSSL_ROOT_DIR)
    set(OPENSSL_ROOT_DIR /usr/local/lib64)
endif ()
# 从根目录寻找cmake配置文件
find_package(OpenSSL 3.5.1 EXACT CONFIG REQUIRED)
# 使用OPEN_SSL的静态库
if (OpenSSL_FOUND)
    set(OPENSSL_USE_STATIC_LIBS TRUE)
endif ()

# ssh2协议远程连接库
find_package(libssh2 CONFIG REQUIRED)

# 在src目录下搜集源码文件
aux_source_directory(src SOURCE_FILES)

# 将模块打包成静态库
add_library(${TARGET}
    STATIC
        ${SOURCE_FILES}
)

# 给模块起个别名，便与其他模块引用(原名的目标依然存在)
add_library(${PROJECT_NAME}::${TARGET} ALIAS ${TARGET})

target_include_directories(${TARGET}
    PUBLIC
        include
)

# 为模块添加依赖
target_link_libraries(${TARGET}
#    PUBLIC
#        OpenSSL::SSL    # ssl/tls协议
#        OpenSSL::Crypto # 加密算法

    PRIVATE
        Boost::format   # 格式化
        Boost::json # Json处理
        asio2   # 网络框架
        libssh2::libssh2_static # ssh协议远程连接库
        go::telnet # ssh和telnet通信
        ${PROJECT_NAME}::database
        ${PROJECT_NAME}::logger
        ${PROJECT_NAME}::sys_config
)

# 给模块增加预编译头文件
target_precompile_headers(${TARGET}
    PRIVATE
        ${PROJECT_INCLUDE_DIR}/pre_compiled.h
)